<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录 - 七牛存储在线管理系统</title>
    <link rel="stylesheet" href="/static/css/layui.css">
    <style>
        body {
            background-color: #005ca9;
        }

        .loginBox {
            width: 350px;
            height: 300px;
            border: solid 1px #eee;
            background-color: #FFF;
            border-radius: 5px;
            margin: 100px auto;
        }

        .projectTitle {
            text-align: center;
            font-size: 20px;
            margin: 50px 0;
        }

        .loginBox .layui-form {
            width: 250px;
            margin: 0 auto;
        }

        .layui-form .layui-input-block {
            margin-left: 50px;
        }
    </style>
</head>
<body>
<div class="loginBox">
    <p class="projectTitle">七牛存储在线管理系统</p>
    <div class="layui-form">
        <div class="layui-form-item">
            <input type="text" name="name" required lay-verify="required" placeholder="请输入账号" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-item">
            <input type="password" name="pass" required lay-verify="required" placeholder="请输入密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="login">登录</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</div>
<script src="/static/layui.js"></script>
<script>
    layui.use(['form', 'layer', 'jquery'], function () {
        var layer = layui.layer;
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)', function (data) {
            $.ajax({
                data: data.field,
                url: '/do.html',
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.code === 200) {
                        layer.msg(data.msg, {
                            icon: 1, time: 2000
                        }, function () {
                            window.location.href = '/';
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 2, time: 2000
                        });
                    }
                },
                error: function () {
                    layer.msg('程序请求失败');
                }
            });
            return false;
        });
    });
</script>
</body>
</html>